<% prefix = resource_name + titlelize(api.name) -%>
func action<%= prefix %>(d *schema.ResourceData, result interface{}, client *golangsdk.ServiceClient) error {
<% if api.path_parameter -%>
    pathParameters := map[string][]string {
<%     api.path_parameter.each do |k, v| -%>
<%=      sprintf("\"%s\": []string{%s},", k, index2navigate(v))  %>
<%     end -%>
    }
    var data = make(map[string]interface{})
    for key, path := range pathParameters {
        value, err := navigateValue(result, path, nil)
        if err != nil {
            return fmt.Errorf("Error retrieving path parameter, err=%s", err)
        }
        data[key] = value
    }
    url, err := replaceVars(d, "<%= api.path -%>", data)
    if err != nil {
        return err
    }
    url = client.ServiceURL(url)
<% elsif api.path.include?("{") -%>
    url, err := replaceVars(d, "<%= api.path -%>", nil)
    if err != nil {
        return err
    }
    url = client.ServiceURL(url)
<% else -%>
    url := client.ServiceURL(<%= sprintf("\"%s\"", api.path) %>)
<% end -%>
<% unless api.parameters.nil? -%>

    params := make(map[string]interface{})
<%= lines(build_expand_properties(api.parameters, "nil, nil", prefix, "params", false), 1) %>
<% end -%>

    r := golangsdk.Result{}
    _, r.Err = client.<%= api.verb.capitalize %>(url, <%= api.parameters.nil? ? "nil" : "params" %>, <%= api.has_response ? "&r.Body" : "nil" %>, &golangsdk.RequestOpts{
        OkCodes: successHTTPCodes,
        <% unless api.header_params.nil? -%>
        MoreHeaders: map[string]string{
          <% api.header_params.each do |k, v| -%>
            <%= sprintf("\"%s\": \"%s\",", k, v)%>
          <% end -%>
        },
        <% end -%>
    })
    if r.Err != nil {
        return fmt.Errorf("Error run action of <%= api.name %>, err=%s", r.Err)
    }
    return nil
}
